<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/all.min.css" integrity="sha256-mUZM63G8m73Mcidfrv5E+Y61y7a12O5mW4ezU3bxqW4=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"tallgy.gitee.io","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="npm包上传到npm官网众所周知，我们可以使用npm i xxx进行下载，npm作为一个包管理的一个工具，我们可以使用别人的包，我们也可以自己在npm上面创建一个属于自己的包，然后使用npm进行下载 首先，肯定是要在 npm 官网上面创建一个账号了1https:&#x2F;&#x2F;www.npmjs.com&#x2F;    然后就是 进入 cmd在本地进行登录1使用 npm login 就可以进行登录  注意点： ​">
<meta property="og:type" content="article">
<meta property="og:title" content="npm-package上传">
<meta property="og:url" content="http://tallgy.gitee.io/2022/01/22/%E9%9A%8F%E7%AC%94/npm-package%E4%B8%8A%E4%BC%A0/index.html">
<meta property="og:site_name" content="tallgy&#39;s blog">
<meta property="og:description" content="npm包上传到npm官网众所周知，我们可以使用npm i xxx进行下载，npm作为一个包管理的一个工具，我们可以使用别人的包，我们也可以自己在npm上面创建一个属于自己的包，然后使用npm进行下载 首先，肯定是要在 npm 官网上面创建一个账号了1https:&#x2F;&#x2F;www.npmjs.com&#x2F;    然后就是 进入 cmd在本地进行登录1使用 npm login 就可以进行登录  注意点： ​">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://tallgy.gitee.io/.io//image-20220122231048580.png">
<meta property="article:published_time" content="2022-01-22T15:02:31.000Z">
<meta property="article:modified_time" content="2023-06-25T08:57:29.354Z">
<meta property="article:author" content="tallgy">
<meta property="article:tag" content="随笔">
<meta property="article:tag" content="npm">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://tallgy.gitee.io/.io//image-20220122231048580.png">


<link rel="canonical" href="http://tallgy.gitee.io/2022/01/22/%E9%9A%8F%E7%AC%94/npm-package%E4%B8%8A%E4%BC%A0/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://tallgy.gitee.io/2022/01/22/%E9%9A%8F%E7%AC%94/npm-package%E4%B8%8A%E4%BC%A0/","path":"2022/01/22/随笔/npm-package上传/","title":"npm-package上传"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>npm-package上传 | tallgy's blog</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">tallgy's blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#npm%E5%8C%85%E4%B8%8A%E4%BC%A0%E5%88%B0npm%E5%AE%98%E7%BD%91"><span class="nav-number">1.</span> <span class="nav-text">npm包上传到npm官网</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%A6%96%E5%85%88%EF%BC%8C%E8%82%AF%E5%AE%9A%E6%98%AF%E8%A6%81%E5%9C%A8-npm-%E5%AE%98%E7%BD%91%E4%B8%8A%E9%9D%A2%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E8%B4%A6%E5%8F%B7%E4%BA%86"><span class="nav-number">1.1.</span> <span class="nav-text">首先，肯定是要在 npm 官网上面创建一个账号了</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%84%B6%E5%90%8E%E5%B0%B1%E6%98%AF-%E8%BF%9B%E5%85%A5-cmd%E5%9C%A8%E6%9C%AC%E5%9C%B0%E8%BF%9B%E8%A1%8C%E7%99%BB%E5%BD%95"><span class="nav-number">1.2.</span> <span class="nav-text">然后就是 进入 cmd在本地进行登录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%80%E4%B8%AA%E5%8C%85"><span class="nav-number">1.3.</span> <span class="nav-text">初始化一个包</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BC%96%E5%86%99%E8%87%AA%E5%B7%B1%E7%9A%84%E5%8C%85%E7%9A%84%E8%BF%87%E7%A8%8B"><span class="nav-number">1.4.</span> <span class="nav-text">编写自己的包的过程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%80%E5%90%8E%EF%BC%8C%E4%B8%8A%E4%BC%A0"><span class="nav-number">1.5.</span> <span class="nav-text">最后，上传</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9B%B4%E6%96%B0-npm"><span class="nav-number">1.6.</span> <span class="nav-text">更新 npm</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">tallgy</p>
  <div class="site-description" itemprop="description">只是一个知识的搬运工</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">107</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">32</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">74</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://tallgy.gitee.io/2022/01/22/%E9%9A%8F%E7%AC%94/npm-package%E4%B8%8A%E4%BC%A0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="tallgy">
      <meta itemprop="description" content="只是一个知识的搬运工">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="tallgy's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          npm-package上传
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-01-22 23:02:31" itemprop="dateCreated datePublished" datetime="2022-01-22T23:02:31+08:00">2022-01-22</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2023-06-25 16:57:29" itemprop="dateModified" datetime="2023-06-25T16:57:29+08:00">2023-06-25</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E9%9A%8F%E7%AC%94/" itemprop="url" rel="index"><span itemprop="name">随笔</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="npm包上传到npm官网"><a href="#npm包上传到npm官网" class="headerlink" title="npm包上传到npm官网"></a>npm包上传到npm官网</h1><p>众所周知，我们可以使用npm i xxx进行下载，npm作为一个包管理的一个工具，我们可以使用别人的包，我们也可以自己在npm上面创建一个属于自己的包，然后使用npm进行下载</p>
<h2 id="首先，肯定是要在-npm-官网上面创建一个账号了"><a href="#首先，肯定是要在-npm-官网上面创建一个账号了" class="headerlink" title="首先，肯定是要在 npm 官网上面创建一个账号了"></a>首先，肯定是要在 npm 官网上面创建一个账号了</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://www.npmjs.com/</span><br></pre></td></tr></table></figure>



<h2 id="然后就是-进入-cmd在本地进行登录"><a href="#然后就是-进入-cmd在本地进行登录" class="headerlink" title="然后就是 进入 cmd在本地进行登录"></a>然后就是 进入 cmd在本地进行登录</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">使用 npm login 就可以进行登录</span><br></pre></td></tr></table></figure>

<p>注意点：</p>
<p>​    这个需要在官网，所以你要知道你现在连接的仓库是</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://registry.npmjs.org/</span><br></pre></td></tr></table></figure>

<p>​    当然我记得现在比较新的npm应该是在登录的时候可以看到自己登录的网站是哪个，</p>
<p>​    如果看不到自己的网站是哪个，那么我们可以使用一个包管理工具 nrm 进行管理</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">npm i -g nrm</span><br><span class="line"></span><br><span class="line">nrm ls</span><br><span class="line">nrm use npm</span><br></pre></td></tr></table></figure>

<p>然后使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">npm login</span><br><span class="line"></span><br><span class="line">输入自己的用户名和密码，然后输入邮箱</span><br></pre></td></tr></table></figure>



<h2 id="初始化一个包"><a href="#初始化一个包" class="headerlink" title="初始化一个包"></a>初始化一个包</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">npm init</span><br><span class="line"></span><br><span class="line">对应的意思是</span><br><span class="line">包名</span><br><span class="line">版本，听说需要从 0.0.1 开始</span><br><span class="line">描述</span><br><span class="line">入口文件</span><br><span class="line">测试指令：应该是，这个没有用过</span><br><span class="line">git 仓库</span><br><span class="line">关键字，可以用于搜索</span><br><span class="line">作者</span><br><span class="line">证书，用MIT，开源管理不会过于严格，不会引起应激反应</span><br><span class="line">然后就是回车回车完事儿</span><br></pre></td></tr></table></figure>

<p><img src="/.io//image-20220122231048580.png" alt="image-20220122231048580"></p>
<h2 id="编写自己的包的过程"><a href="#编写自己的包的过程" class="headerlink" title="编写自己的包的过程"></a>编写自己的包的过程</h2><p>xxxx</p>
<p>然后包编写完了，就是开始上传了</p>
<h2 id="最后，上传"><a href="#最后，上传" class="headerlink" title="最后，上传"></a>最后，上传</h2><p>这个很简单，就是publish就完了。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm publish</span><br></pre></td></tr></table></figure>



<h2 id="更新-npm"><a href="#更新-npm" class="headerlink" title="更新 npm"></a>更新 npm</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">就是修改一下 version</span><br><span class="line">然后 npm publish 就行</span><br></pre></td></tr></table></figure>


    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E9%9A%8F%E7%AC%94/" rel="tag"># 随笔</a>
              <a href="/tags/npm/" rel="tag"># npm</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2022/01/22/JavaScript/JavaScript%E5%AE%9A%E6%97%B6%E5%99%A8/" rel="prev" title="JavaScript定时器">
                  <i class="fa fa-chevron-left"></i> JavaScript定时器
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2022/01/29/elementUI%E6%BA%90%E7%A0%81/elementUI%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90(%E4%B8%80)/" rel="next" title="elementUI源码分析(一)">
                  elementUI源码分析(一) <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">tallgy</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  





  





</body>
</html>
